Page({
  data: {
      winWidth: 0,
      winHeight: 0,
      currentTab: 0,
      colorList: [
          [1,2,3,4,5,6,7],
          [1,2,3,4,5,6,7],
          [1,2,3,4,5,6,7],
          [1,2,3,4,5,6,7],
          [1,2,3,4,5,6,7],
      ],
      lotteryList: [],
  },
  onLoad: function() {

      var that = this;

      /**
       * 获取当前设备的宽高
       */
      wx.getSystemInfo( {

          success: function( res ) {
              that.setData( {
                  winWidth: res.windowWidth,
                  winHeight: res.windowHeight
              });
          }

      });
      return false;
      wx.request({
        url: 'http://localhost:9001/gen/color',
        success(res) {
          var response = res.data;
          var array = new Array();
          response.forEach(element => {
            var obj = element.split(",");
            array.push(obj);
          });
          console.log(array)

          that.setData( { colorList: array });
        }
      })
  },

//  tab切换逻辑
  swichNav: function( e ) {

      var that = this;

      if( this.data.currentTab === e.target.dataset.current ) {
          return false;
      } else {
          that.setData( {
              currentTab: e.target.dataset.current
          })
      }
  },

  bindChange: function( e ) {
      var that = this;
      that.setData( { currentTab: e.detail.current });
      console.log(e.detail.current);
      if (this.lotteryList == null && e.detail.current == 1) {
        wx.request({
          url: 'http://localhost:9001/gen/lottery',
          success(res) {
            var response = res.data;
            var array = new Array();
            response.forEach(element => {
              var obj = element.split(",");
              array.push(obj);
            });
            console.log(array)

            that.setData( { lotteryList: array });
          }
        })
      }
  },
})
